package org.example.classtopia.Utils;

/**
 * ThreadLocal 工具类
 * 用于在当前线程中存储和获取用户信息
 */
public class ThreadLocalUtil {
    
    // 提供线程隔离
    private static final ThreadLocal<Object> THREAD_LOCAL = new ThreadLocal<>();

    // 根据键获取值
    public static <T> T get(){
        return (T) THREAD_LOCAL.get();
    }
    
    // 存储键值对
    public static void set(Object value){
        THREAD_LOCAL.set(value);
    }

    // 清理数据
    public static void remove(){
        THREAD_LOCAL.remove();
    }
}
